//
//  ExcellentideaTableViewCell.m
//  Gxj
//
//  Created by 💋索少杰 on 2017/10/17.
//  Copyright © 2017年 wkq. All rights reserved.
//

#import "ExcellentideaTableViewCell.h"

@implementation ExcellentideaTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        
        //用户点击头像响应
        //头像背景
        [self.contentView addSubview:self.viewIconZY];
        [self.viewIconZY addSubview:self.iconTouxiangZY];
        //用户名字显示
        [self.contentView addSubview:self.nameTextZY];
        //用户等级图标
        [self.contentView addSubview:self.dengjiTBZY];
        //用户等级显示
        [self.contentView addSubview:self.dengjiTextZY];
        //浏览人数图标
        [self.contentView addSubview:self.iconLiulangZY];
        //观看人数
        [self.contentView addSubview:self.liulangNumZY];
        //用户发表内容
        [self.contentView addSubview:self.contentTextZY];
        //发表时间图标
        [self.contentView addSubview:self.iconShijianZY];
        //用户发表时间
        [self.contentView addSubview:self.shijianTextZY];
        //点赞数量
        [self.contentView addSubview:self.dianzanNumZY];
        //点赞图片
        [self.contentView addSubview:self.dianzanIconZY];
        //简介阴影
        [self.contentView addSubview:self.jianJieViewZY];
        //简介内容
        [self.jianJieViewZY addSubview:self.jianjieContextZY];
        //用户发表图片
        [self.contentView addSubview:self.fabiaoImageZY];
        //关注按钮
        [self.contentView addSubview:self.guanzhuZY];
        //最佳讨论文字
        [self.contentView addSubview:self.zuijiaTextZY];
        //最佳用户头像
        //        [self addSubview:self.iconZuijia];
        //添加最佳用户头像
        [self.iconZuijiaZY addSubview:self.addButZY];
        //Cell底部线条
        [self.contentView addSubview:self.lineBackZY];
        //适配方法
        [self setUpadapter];
        
        
        //商业标签
        for (int i = 0; i < 3; i++) {
            _theLabelZY = [[UILabel alloc] initWithFrame:CGRectMake(kWidthScale(5) + kWidthScale(40) * i, kHeightScale(5), kWidthScale(35), kHeightScale(15))];
            
            _theLabelZY.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4];
            _theLabelZY.text = @"商业";
            _theLabelZY.textColor = [UIColor colorWithWhite:1 alpha:1];
            _theLabelZY.font = [UIFont systemFontOfSize:kWidthScale(9)];
            _theLabelZY.textAlignment = NSTextAlignmentCenter;
            _theLabelZY.layer.cornerRadius = kWidthScale(5);
            _theLabelZY.layer.masksToBounds = YES;
            
            [self.fabiaoImageZY addSubview:self.theLabelZY];
        }
        
        //最佳头像
        //最佳用户头像
        for (int i = 0; i < 5; i++) {
            _iconZuijiaZY = [[UIImageView alloc] initWithFrame:CGRectMake(kWidthScale(84) * (i+1) - (66*i), kHeightScale(263), kWidthScale(20), kHeightScale(20))];
            
            _iconZuijiaZY.image=[UIImage imageNamed:@"toixiang"];
            [self.contentView addSubview:_iconZuijiaZY];
            
        }
        
    }
    return self;
}


//适配方法
- (void)setUpadapter
{
    //头像背景
    _viewIconZY.sd_layout
    .topSpaceToView(self.contentView, kHeightScale(11))
    .leftSpaceToView(self.contentView, kWidthScale(15))
    .widthIs(kWidthScale(25))
    .heightIs(kHeightScale(25));
    
    //头像
    _iconTouxiangZY.sd_layout
    .topSpaceToView(self.viewIconZY, kHeightScale(1.5))
    .leftSpaceToView(self.viewIconZY, kWidthScale(1.5))
    .widthIs(kWidthScale(22))
    .heightIs(kHeightScale(22));
    
    //名字
    _nameTextZY.sd_layout
    .topSpaceToView(self.contentView, kHeightScale(10))
    .leftSpaceToView(self.viewIconZY, kWidthScale(5))
    .widthIs(kWidthScale(100))
    .autoHeightRatio(0);
    
    //等级图标
    _dengjiTBZY.sd_layout
    .topSpaceToView(self.nameTextZY, kHeightScale(3))
    .leftSpaceToView(self.viewIconZY, kWidthScale(5))
    .widthIs(kWidthScale(11))
    .heightIs(kHeightScale(11));
    //等级时间
    _dengjiTextZY.sd_layout
    .centerYEqualToView(self.dengjiTBZY)
    .leftSpaceToView(self.dengjiTBZY, kWidthScale(3))
    .widthIs(kWidthScale(30))
    .autoHeightRatio(0);
    //发表内容
    _contentTextZY.sd_layout
    .topSpaceToView(self.viewIconZY, kHeightScale(5))
    .leftSpaceToView(self.contentView, kWidthScale(15))
    .rightSpaceToView(self.contentView, kWidthScale(15))
    .autoHeightRatio(0);
    
    //时间图标
    //    _iconShijian.sd_layout
    //    .topSpaceToView(self.contentText, kHeightScale(5))
    //    .leftSpaceToView(self.contentView, kWidthScale(15))
    //    .widthIs(kWidthScale(15))
    //    .heightIs(kHeightScale(15));
    _iconShijianZY.sd_layout
    .topSpaceToView(self.contentTextZY,kHeightScale(5))
    .leftEqualToView(self.viewIconZY)
    .widthIs(kWidthScale(13))
    .heightIs(kHeightScale(13));
    //时间
    _shijianTextZY.sd_layout
    .topSpaceToView(self.contentTextZY, kHeightScale(4))
    .leftSpaceToView(self.iconShijianZY, kWidthScale(5))
    .widthIs(kWidthScale(40))
    .autoHeightRatio(0);
    //浏览图标
    _iconLiulangZY.sd_layout
    .topSpaceToView(self.contentTextZY, kHeightScale(7))
    .leftSpaceToView(self.shijianTextZY, kWidthScale(5))
    .widthIs(kWidthScale(13))
    .heightIs(kHeightScale(8.6));
    //浏览人数
    _liulangNumZY.sd_layout
    .topEqualToView(self.shijianTextZY)
    .leftSpaceToView(self.iconLiulangZY, kWidthScale(5))
    .widthIs(kWidthScale(35))
    .autoHeightRatio(0);
    //点赞图片
    _dianzanIconZY.sd_layout
    .topSpaceToView(self.contentTextZY, kHeightScale(5))
    .leftSpaceToView(self.liulangNumZY, kWidthScale(10))
    .widthIs(kWidthScale(12))
    .heightIs(kHeightScale(12));
    //点赞数量
    _dianzanNumZY.sd_layout
    .topEqualToView(self.shijianTextZY)
    .leftSpaceToView(self.dianzanIconZY, kWidthScale(5))
    .widthIs(kWidthScale(50))
    .autoHeightRatio(0);
    //简介View阴影
    _jianJieViewZY.sd_layout
    .topSpaceToView(self.shijianTextZY, kHeightScale(10))
    .leftSpaceToView(self.contentView, kWidthScale(15))
    .rightSpaceToView(self.contentView, kWidthScale(15))
    .heightIs(kHeightScale(49));
    //简介
    _jianjieContextZY.sd_layout
    .topSpaceToView(self.jianJieViewZY, 0)
    .leftSpaceToView(self.jianJieViewZY, 0)
    .rightSpaceToView(self.jianJieViewZY, 0)
    .heightIs(kHeightScale(49));
    //发表图片
    _fabiaoImageZY.sd_layout
    .topSpaceToView(self.jianJieViewZY, kHeightScale(10))
    .leftSpaceToView(self.contentView, kWidthScale(15))
    .rightSpaceToView(self.contentView, kWidthScale(15))
    .heightIs(kHeightScale(110));
    //最佳文字
    _zuijiaTextZY.sd_layout
    .topSpaceToView(self.fabiaoImageZY, kHeightScale(10))
    .leftSpaceToView(self.contentView, kWidthScale(15))
    .widthIs(kWidthScale(50))
    .autoHeightRatio(0);
    //最佳添加按钮
    _addButZY.sd_layout
    .topSpaceToView(self.iconZuijiaZY,kHeightScale(0))
    .leftSpaceToView(self.iconZuijiaZY, kWidthScale(-5))
    .widthIs(kWidthScale(20))
    .heightIs(kHeightScale(20));
    //关注
    _guanzhuZY.sd_layout
    .topSpaceToView(self.contentView,kHeightScale(10))
    .rightSpaceToView(self.contentView,kWidthScale(15))
    .widthIs(kWidthScale(44))
    .heightIs(kHeightScale(25));
    //cell底部的线条
    _lineBackZY.sd_layout
    .bottomSpaceToView(self.contentView, 0)
    .leftSpaceToView(self.contentView, 0)
    .rightSpaceToView(self.contentView, 0)
    .heightIs(kHeightScale(5));
    
}
//头像背景
- (UIView *)viewIconZY
{
    if (!_viewIconZY)
    {
        _viewIconZY=[[UIView alloc] init];
        _viewIconZY.backgroundColor = [UIColor colorWithRed:(213.0/255) green:(213.0/255) blue:(213.0/255) alpha:1];;
        _viewIconZY.layer.masksToBounds=YES;
        _viewIconZY.layer.cornerRadius=12.5;
        _viewIconZY.layer.shadowColor = [UIColor blackColor].CGColor;
        _viewIconZY.layer.shadowOffset = CGSizeMake(-3, 1);
        _viewIconZY.layer.shadowOpacity = 0.4;
        _viewIconZY.layer.shadowRadius = 2.0;
        _viewIconZY.clipsToBounds = NO;
    }
    return _viewIconZY;
}
//头像
- (UIButton *)iconTouxiangZY
{
    if (!_iconTouxiangZY)
    {
        _iconTouxiangZY=[[UIButton alloc] init];
        [_iconTouxiangZY setBackgroundImage:[UIImage imageNamed:@"toixiang"] forState:UIControlStateNormal];
    }
    return _iconTouxiangZY;
}
//名字
- (UILabel *)nameTextZY
{
    if (!_nameTextZY)
    {
        _nameTextZY=[[UILabel alloc] init];
        _nameTextZY.text=@"后悔的小公主";
        _nameTextZY.font = [UIFont systemFontOfSize:kWidthScale(12)];
        _nameTextZY.textColor = [UIColor colorWithHexString:@"#333333"];
    }
    return _nameTextZY;
}
//等级图标
- (UIImageView *)dengjiTBZY
{
    if (!_dengjiTBZY)
    {
        _dengjiTBZY=[[UIImageView alloc] init];
        _dengjiTBZY.image=[UIImage imageNamed:@"dengjis"];
    }
    return _dengjiTBZY;
}
//等级
- (UILabel *)dengjiTextZY
{
    if (!_dengjiTextZY)
    {
        _dengjiTextZY=[[UILabel alloc] init];
        _dengjiTextZY.text=@"100级";
        _dengjiTextZY.textColor=[UIColor colorWithRed:(153.0/255) green:(153.0/255) blue:(153.0/255) alpha:1];
        _dengjiTextZY.font=[UIFont systemFontOfSize:kWidthScale(10)];
    }
    return _dengjiTextZY;
}
//用户发表动态
- (UILabel *)contentTextZY
{
    if (!_contentTextZY)
    {
        _contentTextZY=[[UILabel alloc] init];
        _contentTextZY.text=@"梦想有多大就能飞多远";
        _contentTextZY.textColor = [UIColor colorWithHexString:@"#333333"];
        _contentTextZY.font=[UIFont systemFontOfSize:kWidthScale(14)];
    }
    return _contentTextZY;
}
//发表时间图标
- (UIImageView *)iconShijianZY
{
    if (!_iconShijianZY)
    {
        _iconShijianZY=[[UIImageView alloc] init];
        _iconShijianZY.image=[UIImage imageNamed:@"time"];
    }
    return _iconShijianZY;
}
//发表时间
- (UILabel *)shijianTextZY
{
    if (!_shijianTextZY)
    {
        _shijianTextZY=[[UILabel alloc] init];
        _shijianTextZY.text=@"15:20";
        _shijianTextZY.textColor=[UIColor colorWithRed:(153.0/255) green:(153.0/255) blue:(153.0/255) alpha:1];
        _shijianTextZY.font=[UIFont systemFontOfSize:kWidthScale(12)];
    }
    return _shijianTextZY;
}
//浏览图标
- (UIImageView *)iconLiulangZY
{
    if (!_iconLiulangZY)
    {
        _iconLiulangZY=[[UIImageView alloc] init];
        _iconLiulangZY.image=[UIImage imageNamed:@"liulans"];
    }
    return _iconLiulangZY;
}
//浏览人数
- (UILabel *)liulangNumZY
{
    if (!_liulangNumZY)
    {
        _liulangNumZY=[[UILabel alloc] init];
        _liulangNumZY.text=@"8461";
        _liulangNumZY.textColor=[UIColor colorWithRed:(153.0/255) green:(153.0/255) blue:(153.0/255) alpha:1];
        _liulangNumZY.font=[UIFont systemFontOfSize:kWidthScale(12)];
    }
    return _liulangNumZY;
}
//点赞图片
- (UIImageView *)dianzanIconZY
{
    if (!_dianzanIconZY)
    {
        _dianzanIconZY=[[UIImageView alloc] init];
        _dianzanIconZY.image=[UIImage imageNamed:@"zans"];
    }
    return _dianzanIconZY;
}
//点赞数量
- (UILabel *)dianzanNumZY
{
    if (!_dianzanNumZY)
    {
        _dianzanNumZY=[[UILabel alloc] init];
        _dianzanNumZY.text=@"1000";
        _dianzanNumZY.textColor=[UIColor colorWithRed:(153.0/255) green:(153.0/255) blue:(153.0/255) alpha:1];
        _dianzanNumZY.font=[UIFont systemFontOfSize:kWidthScale(12)];
    }
    return _dianzanNumZY;
}
//背景颜色
- (UIView *)jianJieViewZY
{
    if (!_jianJieViewZY)
    {
        _jianJieViewZY = [[UIView alloc] init];
        _jianJieViewZY.layer.shadowColor = [UIColor blackColor].CGColor;
        _jianJieViewZY.layer.shadowOffset = CGSizeMake(0, 1);
        _jianJieViewZY.layer.shadowOpacity = 0.2;
        //        _shadowView.layer.shadowRadius = 6.0;
        //        _shadowView.layer.cornerRadius = 6.0;
        _jianJieViewZY.clipsToBounds = NO;
    }
    return _jianJieViewZY;
}
//简介内容
- (KQlable *)jianjieContextZY
{
    if (!_jianjieContextZY)
    {
        _jianjieContextZY = [[KQlable alloc] init];
        _jianjieContextZY.text = @"风暴简介：个环境可凉快和包教包零零落落零零落落零零落落零零落落零零落落啦啦啦\n";
        _jianjieContextZY.backgroundColor = [UIColor colorWithRed:251.0/255 green:251.0/255 blue:251.0/255 alpha:1];
        _jianjieContextZY.textColor = [UIColor colorWithHexString:@"#666666"];
        _jianjieContextZY.font=[UIFont systemFontOfSize:kWidthScale(11)];
        _jianjieContextZY.layer.cornerRadius = kWidthScale(10);
        _jianjieContextZY.layer.masksToBounds = YES;
        _jianjieContextZY.numberOfLines=0;
        //        NSDictionary *attrDict1 = @{ NSForegroundColorAttributeName: [UIColor colorWithHexString:@"#666666"] };
        //        NSString *str = @"风暴简介：";
        //        _jianjieContext.attributedText = [[NSAttributedString alloc] initWithString: str attributes: attrDict1];
        
        [KQlable changeLineSpaceForLabel:_jianjieContextZY WithSpace:5.0f];
    }
    return _jianjieContextZY;
}
- (void)drawTextInRect:(CGRect)rect {
    UIEdgeInsets insets = {0, 5, 0, 5};
    [self drawTextInRect:UIEdgeInsetsInsetRect(rect, insets)];
}

//发表图片
- (UIImageView *)fabiaoImageZY
{
    if (!_fabiaoImageZY)
    {
        _fabiaoImageZY=[[UIImageView alloc] init];
        _fabiaoImageZY.image=[UIImage imageNamed:@"banner"];
        _fabiaoImageZY.layer.masksToBounds=YES;
        _fabiaoImageZY.layer.cornerRadius=kWidthScale(12);
    }
    return _fabiaoImageZY;
}
//最佳讨论
- (UILabel *)zuijiaTextZY
{
    if (!_zuijiaTextZY)
    {
        _zuijiaTextZY=[[UILabel alloc] init];
        _zuijiaTextZY.text=@"最佳讨论";
        _zuijiaTextZY.textColor=[UIColor colorWithRed:(102.0/255) green:(102.0/255) blue:(102.0/255) alpha:1];
        _zuijiaTextZY.font=[UIFont systemFontOfSize:kWidthScale(12)];
    }
    return _zuijiaTextZY;
}

//添加最佳讨论人头像
- (UIButton *)addButZY
{
    if (!_addButZY)
    {
        _addButZY=[[UIButton alloc] init];
        [_addButZY setBackgroundImage:[UIImage imageNamed:@"jias"] forState:UIControlStateNormal];
    }
    return _addButZY;
}
//关注
- (UIButton *)guanzhuZY
{
    if (!_guanzhuZY)
    {
        _guanzhuZY = [UIButton buttonWithType:UIButtonTypeCustom];
        [_guanzhuZY setBackgroundImage:[UIImage imageNamed:@"guanzhu"] forState:0];
        _guanzhuZY.contentMode = UIViewContentModeScaleAspectFit;
    }
    return _guanzhuZY;
}
//cell底部的线条
- (UILabel *)lineBackZY
{
    if (!_lineBackZY)
    {
        _lineBackZY=[[UILabel alloc] init];
        _lineBackZY.backgroundColor=[UIColor colorWithRed:242.0/255.0 green:242.0/255.0 blue:242.0/255.0 alpha:1];
        //        _lineBack.backgroundColor=[UIColor orangeColor];
    }
    return _lineBackZY;
}


@end
